package com.zr.serviceimpl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.zr.dao.DistributionRangePriceDaoLPN;
import com.zr.dao.Functiondao;
import com.zr.service.DistributionRangePriceServiceLPN;
import com.zr.vo.Drp_dpVO;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;

@Service("DistributionRangePriceServiceLPN")
public class DistributionRangePriceServiceImplLPN implements DistributionRangePriceServiceLPN{

	//属性注入
			@Resource
			private  DistributionRangePriceDaoLPN drpDao;
	@Override
	public JSONObject getDistributionRangePrice(int page,int rows) {
		JSONObject j = new JSONObject();
		List<Drp_dpVO> ss = drpDao.getDistributionRangePrice(page, rows);
		JSONArray ja = new JSONArray();
		for (Drp_dpVO Drp_dpVO : ss) {
			JSONObject jo = new JSONObject();
			jo.put("drpId", Drp_dpVO.getDrpId());
			jo.put("drpFirstKilogramPrice",Drp_dpVO.getDrpFirstKilogramPrice());
			jo.put("drpNextKilogramPrice", Drp_dpVO.getDrpNextKilogramPrice());
			jo.put("drpFirstCubicPrice",Drp_dpVO.getDrpFirstCubicPrice() );
			jo.put("drpNextCubicPrice", Drp_dpVO.getDrpNextCubicPrice());
			jo.put("drpRemarks", Drp_dpVO.getDrpRemarks());
			jo.put("dsName", Drp_dpVO.getDsName());			
			jo.put("dpName",Drp_dpVO.getDpName() );
			jo.put("otName", Drp_dpVO.getOtName());
			ja.add(jo);
		}
		j.put("total", drpDao.getDistributionRangePriceCount());
		j.put("rows", ja);
		return j;
	}
	@Override
	public boolean insertDRP(Double drpFirstKilogramPrice,Double drpNextKilogramPrice,Double drpFirstCubicPrice,Double drpNextCubicPrice,String drpRemarks,int dsId,int otId) {
		// TODO Auto-generated method stub
		return drpDao.insertDRP(drpFirstKilogramPrice, drpNextKilogramPrice, drpFirstCubicPrice, drpNextCubicPrice, drpRemarks, dsId, otId);
	}
	@Override
	public int updateDRP(int drpId, Double drpFirstKilogramPrice, Double drpNextKilogramPrice,
			Double drpFirstCubicPrice, Double drpNextCubicPrice, String drpRemarks) {
		// TODO Auto-generated method stub
		return drpDao.updateDRP(drpId, drpFirstKilogramPrice, drpNextKilogramPrice, drpFirstCubicPrice, drpNextCubicPrice, drpRemarks);
	}

}
